<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title>Tables - Ace Admin</title>

</head>

<body class="no-skin">
	<table id="sample-table-1"
		class="table table-striped table-bordered table-hover">
		<tr>
			<td><a href="changeLocale?localeType=en_US"> <spring:message
						code="page.index.english" /></a></td>
			<td><a href="changeLocale?localeType=zh_CN"><spring:message
						code="page.index.chinese" /></a></td>
		</tr>
		<tr>
			<td colspan="6"><a href="add" class="btn btn-info btn-lg"> <span
					class="glyphicon glyphicon-plus-sign"></span> <spring:message
						code="page.index.add" />
			</a>
				<button id="batchAddStudentBtn" class="btn btn-info btn-lg">
					<span class="glyphicon glyphicon-plus-sign"></span> 批量添加学生信息
				</button></td>

		</tr>
		<tr>
			<th>${user_id }</th>
			<th>${user_name }</th>
			<th>${gender}</th>
			<th>${birthday }</th>
			<th>${tel }</th>
			<th>${address }</th>
			<th>${operate}</th>
		</tr>
		<c:forEach items="${studentList.dates }" var="list">
			<tr>
				<td>${list.user_id }</td>
				<td>${list.user_name }</td>
				<td>${list.gender=="0"?"男":"女" }</td>
				<td>${list.birthday }</td>
				<td>${list.tel }</td>
				<td>${list.address }</td>
				<td><a class="green edit-test" href="edit/${list.user_id }"
					title="修改学生"> <i class="ace-icon fa fa-pencil bigger-130"></i>
				</a>&nbsp;<a class="red delete-test" href="delete/${list.user_id }"
					title="删除学生" onclick="msg();"> <i
						class="ace-icon fa fa-trash-o bigger-130"></i>
				</a></td>
			</tr>

		</c:forEach>
		<tr>
			<td colspan="4"><jsp:include page="page.jsp">
					<jsp:param name="url" value="${pageContext.request.contextPath }/students" />
					<jsp:param name="items" value="${studentList.totalSize }" />
				</jsp:include></td>
		</tr>
	</table>


	<!-- 模态框（Modal）上传 -->
	<div class="modal fade" id="uploadFileModal" tabindex="-1"
		role="dialog" aria-labelledby="showTestModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<form:form method="post"
					action="${pageContext.request.contextPath }/uploadFile"
					enctype="multipart/form-data">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">&times;</button>
						<h4 class="modal-title" id="myModalLabel">上传</h4>
					</div>
					<div class="modal-body">
						<input id="uploadFile" name="uploadFile" type="file"
							class="form-control" />
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button id="subjectStudentSaveBtn" type="submit"
							class="btn btn-primary">保存</button>
					</div>
				</form:form>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal -->
	</div>

	<script type="text/javascript">
		jQuery(function($) {
			//显示上传控制样式
			$('#uploadFile').ace_file_input({
				style : 'well',
				btn_choose : 'Drop files here or click to choose',
				btn_change : null,
				no_icon : 'ace-icon fa fa-cloud-upload',
				droppable : true,
				thumbnail : 'small',
				preview_error : function(filename, error_code) {
				}
			}).on('change', function() {

			});

			//弹出批量添加弹出框
			$('#batchAddStudentBtn').click(function() {

				$('#uploadFileModal').modal('show');
			});

			//保存并导入excel数据进行批量添加学生
			$('#subjectStudentSaveBtn1').on('click', function() {

				$.ajaxFileUpload({
					url : '${contextPath}/teacher/uploadFile', //用于文件上传的服务器端请求地址
					type : 'POST',
					secureuri : false, //一般设置为false
					fileElementId : $('uploadFile').serialize(), //文件上传控件的id属性  <input type="file" id="file" name="file" /> 注意，这里一定要有name值   
					//$("form").serialize(),表单序列化。指把所有元素的ID，NAME 等全部发过去
					dataType : 'json',//返回值类型 一般设置为json
					complete : function(data) {//只要完成即执行，最后执行
					},
					success : function(data, status) //服务器成功响应处理函数
					{
						if (data.success) {
							alert('成功');
						} else {
							alert(data.messageMap.message);
						}
					},
					error : function(data, status, e)//服务器响应失败处理函数
					{
						alert(e);
					}
				});
			});
		})
		function msg() {
			if (!confirm("你确认要删除吗？"))
				window.event.returnValue = false;
		}
	</script>
</body>
</html>
